package com.bbs.junit;

import static org.junit.Assert.fail;

import java.util.Iterator;
import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.bbs.entity.Post;
import com.bbs.service.PostService;

public class PostServiceTest {
	ApplicationContext cxt = new FileSystemXmlApplicationContext(
			"/WebRoot/WEB-INF/applicationContext.xml");
	PostService ps = (PostService) cxt.getBean("postServiceImpl");

	@Test
	public void testPublishPost() {
	
	}

	@Test
	public void testDeletePost() {
		ps.deletePost(1);
	}

	@Test
	public void testUpdatePost() {
		ps.updatePost("woaini", "niaiwo", 2);
	}

	@Test
	public void testLookPostDetail() {
//		List<Post> list=ps.lookNewPostByBoardId(1);
//		System.out.println(list.get(list.size()-1).getPostContent());
		
	}

	@Test
	public void testReplyPost() {
		ps.replyPost("222222", "3", 2);
	}

	@Test
	public void testVotePost() {
		ps.votePost(3, 1);
	}

	@Test
	public void testSetPostState() {
		ps.setPostState(1, 2);
	}

	@Test
	public void testLookUserPublishPost() {
		List<Post> list = ps.lookUserPublishPost(1);
		Iterator<Post> iter = list.iterator();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(iter.next().getUser().getUserName());
		}
	}

	@Test
	public void testLookUserReplyPost() {
		fail("Not yet implemented");
	}

	@Test
	public void testLookAllPost() {
		fail("Not yet implemented");
	}

	@Test
	public void testLookBoardPostNormal() {
		List<Post> list = ps.lookBoardPostNormal(1);

		Iterator<Post> iter = list.iterator();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(iter.next().getPostName());
		}
	}

	@Test
	public void testLookBoardPostSpecial() {
		List<Post> list = ps.lookBoardPostSpecial(1);
		Iterator<Post> iter = list.iterator();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(iter.next().getPostName());
		}
	}

	@Test
	public void testSetPostTheme() {
		ps.setPostTheme(1, 2);
	}

	@Test
	public void testGetTodayPostCount() {
		int i = ps.getTodayPostCount(1);
		System.out.println(i);
	}

	@Test
	public void testGetYestodayPostCount() {
		int i = ps.getYestodayPostCount();
		System.out.println(i);
	}

	@Test
	public void testGetTodayPostCount1() {
		int i = ps.getTodayPostCount();
		System.out.println(i);
	}

	@Test
	public void testGetAllPostCount() {
		int i = ps.getAllPostCount();
		System.out.println(i);
	};

	@Test
	public void testGetPostCountByBoardId() {
		int i = ps.getPostCountByBoardId(1);
		System.out.println(i);
	}
}
